const cosmos_strgate = require("@cosmjs/stargate");

class Client {
    constructor(nodeUrl) {
    this.nodeUrl= nodeUrl;
    this.client = null;
    }

    async getClient() {
        this.client = await cosmos_strgate.StargateClient.connect(this.nodeUrl);
        
    }
    async getBlockNumberSync() {
        let blockNumber =await  this.client.getHeight();
        return blockNumber;
    }

    async getBlock(blockNumber) {
        let block = await this.client.getBlock(blockNumber);
        return block;
    }
    async getTx(txHash) {
        let tx = await this.client.getTx(txHash);
        return tx;
    }
}

module.exports = Client;
